#! /usr/bin/perl -w
#------------------------------------------------
# Author:    kvkrishna
# Created:   Mon Aug  8 14:19:22 IST 2011
# File Name: Snake
# USAGE: 
# 
# 
# 
#------------------------------------------------
sub Rotate {                                                            # Rotate my compass!!!
  if ($_[0] eq 'Right') { push @Compass, shift @Compass; }
  if ($_[0] eq 'Left') { unshift @Compass, pop @Compass; }
}
#------------------------------------------------
chomp ( $LINES = `tput lines`) ;                                        # Stadium dimentions
chomp ( $COLS  = `tput cols` ) ;                                        # Stadium dimentions
$SnakeLength            = 10 ;                                          # My length
@Compass                = ('North', 'East', 'South', 'West');           # Compass[0] gives my direction
@North                  = (-1, 0);                                      # X and Y increments based on direction
@East                   = ( 0, 1);                                      # X and Y increments based on direction
@West                   = ( 0,-1);                                      # X and Y increments based on direction
@South                  = ( 1, 0);                                      # X and Y increments based on direction
while (int rand 4) { Rotate 'Left';}                                    # Rotate sometimes to get initial random direction
($Inc{x}, $Inc{y})      = @{$Compass[0]};                               # Learning how to move...
print "LINES       : $LINES      \n";
print "COLS        : $COLS       \n";
print "SnakeLength : $SnakeLength\n";
print "Compass     : @Compass    \n";
print "North       : @North      \n";
print "East        : @East       \n";
print "West        : @West       \n";
print "South       : @South      \n";
print "$Inc{x} $Inc{y}\n";
